import mock from "mockjs";
let list = mock.mock({
  "list|10": [
    {
      "id|+1": 1,
      title: "@cname",
      description: "@cparagraph(1, 2)",
      "price|100-1000": 100,
      createTime: "@date",
      userId: 1,
    },
  ],
});
export function goodsListMock(req) {
  console.log(JSON.parse(req.body));
  const params = JSON.parse(req.body);
  const { pageNum = 1, pageSize = 10, title = "", description } = params;
  let fileList = list.list;
  fileList = fileList.filter((item) => {
    return item.title.includes(title);
  });
  if (description) {
    fileList = fileList.filter((item) => {
      return item.description.includes(description);
    });
  }
  return {
    code: 200,
    msg: "获取商品列表成功",
    data: {
      list: fileList,
      count: fileList.length,
    },
  };
}
